class SharingMailer < ActionMailer::Base

  def request(inviter, invitee, url=nil)
    setup_email(invitee)
    @subject    += "Sharing Request from #{inviter.first_name} #{inviter.last_name}"
    @body["inviter"] = "#{inviter.first_name} #{inviter.last_name}"
    @body["invitee"] = "#{invitee.first_name} #{invitee.last_name}"
    @body["url"] = url || UserSystem::CONFIG[:app_url].to_s
    @body["app_name"] = UserSystem::CONFIG[:app_name].to_s
    @recipients = invitee.email
  end
  
  def setup_email(user)
    @recipients = "#{user.email}"
    @from       = UserSystem::CONFIG[:email_from].to_s
    @subject    = "[#{UserSystem::CONFIG[:app_name]}] "
    @sent_on    = Time.now
    @headers['Content-Type'] = "text/plain; charset=#{UserSystem::CONFIG[:mail_charset]}; format=flowed"
  end

end
